package com.powernode.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.powernode.domain.User;
import com.powernode.dto.UserDto;
import com.powernode.mapper.UserMapper;
import com.powernode.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public User login(String username, String md5) {
        System.out.println("1111");
        return userMapper.login(username,md5);
    }

    @Override
    public int insertSelective(User record) {
        return userMapper.insertSelective(record);
    }

    @Override
    public int updateByPrimaryKeySelective(User record) {
        return userMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public PageInfo<User> queryAllUser(UserDto userDto) {
        Page<User> page = PageHelper.startPage(userDto.getPage(), userDto.getLimit());

        List<User> users = userMapper.queryAllUser(userDto);

        return page.toPageInfo();
    }

    @Override
    public List<User> queryAllAvailableUser() {
        return userMapper.queryAllAvailableUser();
    }
}
